#region Developer's comment header
/* Iters.cs
 * 
 * author:    DS2171
 * copyright: DS2171
 * 
 * history:   15/11/2010, DS2171: Created.
 *
 */
#endregion
#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml.Serialization;

using Chili.Opf3;
using Chili.Opf3.Relations;


#endregion

namespace DocManagerORM.Entità
{
	/// <summary>
	/// Persistent object for the "Iters" table.
	/// </summary>
	[Serializable]
	[Persistent("Iters")]
	public partial class Iters : IObjectNotification, ISelfContainingObject, INotifyPropertyChanged, IIters
	{
		#region Fields

		private int _id;
		private int? _progressivo;
		private int _fk_IDItersManager;
		private string _titolo;
		private int _fk_IDDoc;
		private Guid _fk_IDUser_Destinatario = Guid.NewGuid();
		private string _destinatario;
		private int _fk_IDAttivitaIter;
		private string _messaggio;
		private int? _urgenza;
		private DateTime? _scadenza;
		private Guid _fk_IDUser_Mittente = Guid.NewGuid();
		private string _mittente;
		private int? _fk_IDAttivitaIterStato;
		private DateTime? _dataCambioStato;
		private string _messaggioRitorno;
		private bool _isTerminated;

		#endregion

		#region Relations

		[Relation("Fk_IDUser_Destinatario = UserId; Fk_IDUser_Mittente = UserId; Fk_IDUser_Destinatario = UserId", PersistRelationship = PersistRelationships.ChildFirst)]
		private ObjectHolder<aspnet_Users> _aspnet_Users = new ObjectHolder<aspnet_Users>();

		/// <summary>
		/// Specifies the connected "aspnet_Users" persistent object.
		/// </summary>
		[XmlIgnore]
		public aspnet_Users aspnet_Users
		{
			get { return _aspnet_Users.InnerObject; }
			set { _aspnet_Users.InnerObject = value; }
		}

		[Relation("Fk_IDAttivitaIter = ID; Fk_IDAttivitaIterStato = ID; Fk_IDAttivitaIterStato = ID", PersistRelationship = PersistRelationships.ChildFirst)]
		private ObjectHolder<AttivitaIter> _attivitaIter = new ObjectHolder<AttivitaIter>();

		/// <summary>
		/// Specifies the connected "AttivitaIter" persistent object.
		/// </summary>
		[XmlIgnore]
		public AttivitaIter AttivitaIter
		{
			get { return _attivitaIter.InnerObject; }
			set { _attivitaIter.InnerObject = value; }
		}

		[Relation("Fk_IDDoc = ID", PersistRelationship = PersistRelationships.ChildFirst)]
		private ObjectHolder<Documenti> _documenti = new ObjectHolder<Documenti>();

		/// <summary>
		/// Specifies the connected "Documenti" persistent object.
		/// </summary>
		[XmlIgnore]
		public Documenti Documenti
		{
			get { return _documenti.InnerObject; }
			set { _documenti.InnerObject = value; }
		}

		[Relation("Fk_IDItersManager = ID", PersistRelationship = PersistRelationships.ChildFirst)]
		private ObjectHolder<ItersManager> _itersManager = new ObjectHolder<ItersManager>();

		/// <summary>
		/// Specifies the connected "ItersManager" persistent object.
		/// </summary>
		[XmlIgnore]
		public ItersManager ItersManager
		{
			get { return _itersManager.InnerObject; }
			set { _itersManager.InnerObject = value; }
		}

		#endregion

		#region Properties

		/// <summary>
		/// Returns the identifier of the persistent object. Don't set it manually!
		/// </summary>
		[Field("ID", AllowDBNull = false, Identifier = true, AutoNumber = true)]
		public int ID
		{
			get 
			{ 
				return _id; 
			}
			private set 
			{
				_id = value;

				OnRowChanged("ID");
			}
		}

		/// <summary>
		/// This property is mapped to the "Progressivo" field.  
		/// Storage comment: .
		/// </summary>
		[Field("Progressivo")]
		public int? Progressivo
		{
			get 
			{ 
				return _progressivo; 
			}
			set 
			{
				_progressivo = value;

				OnRowChanged("Progressivo");
			}
		}

		/// <summary>
		/// The foreign key connected with another persistent object.
		/// </summary>
		[Field("Fk_IDItersManager", AllowDBNull = false)]
		public int Fk_IDItersManager
		{
			get 
			{ 
				return _fk_IDItersManager; 
			}
			private set 
			{
				_fk_IDItersManager = value;

				OnRowChanged("Fk_IDItersManager");
			}
		}

		/// <summary>
		/// This property is mapped to the "Titolo" field. Length must be between 0 and 150 characters. Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("Titolo", AllowDBNull = false)]
		public string Titolo
		{
			get 
			{ 
				return _titolo; 
			}
			set 
			{
				if (value == null)
					throw new ArgumentNullException("value", "Value is null.");
				if (value != null && value.Length > 150)
					throw new ArgumentException("Value length must be between 0 and 150 characters.");

				_titolo = value;

				OnRowChanged("Titolo");
			}
		}

		/// <summary>
		/// The foreign key connected with another persistent object.
		/// </summary>
		[Field("Fk_IDDoc", AllowDBNull = false)]
		public int Fk_IDDoc
		{
			get 
			{ 
				return _fk_IDDoc; 
			}
			private set 
			{
				_fk_IDDoc = value;

				OnRowChanged("Fk_IDDoc");
			}
		}

		/// <summary>
		/// The foreign key connected with another persistent object.
		/// </summary>
		[Field("Fk_IDUser_Destinatario", AllowDBNull = false)]
		public Guid Fk_IDUser_Destinatario
		{
			get 
			{ 
				return _fk_IDUser_Destinatario; 
			}
			private set 
			{
				_fk_IDUser_Destinatario = value;

				OnRowChanged("Fk_IDUser_Destinatario");
			}
		}

		/// <summary>
		/// This property is mapped to the "Destinatario" field. Length must be between 0 and 50 characters. Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("Destinatario", AllowDBNull = false)]
		public string Destinatario
		{
			get 
			{ 
				return _destinatario; 
			}
			set 
			{
				if (value == null)
					throw new ArgumentNullException("value", "Value is null.");
				if (value != null && value.Length > 50)
					throw new ArgumentException("Value length must be between 0 and 50 characters.");

				_destinatario = value;

				OnRowChanged("Destinatario");
			}
		}

		/// <summary>
		/// The foreign key connected with another persistent object.
		/// </summary>
		[Field("Fk_IDAttivitaIter", AllowDBNull = false)]
		public int Fk_IDAttivitaIter
		{
			get 
			{ 
				return _fk_IDAttivitaIter; 
			}
			private set 
			{
				_fk_IDAttivitaIter = value;

				OnRowChanged("Fk_IDAttivitaIter");
			}
		}

		/// <summary>
		/// This property is mapped to the "Messaggio" field. Length must be between 0 and -1 characters. 
		/// Storage comment: .
		/// </summary>
		[Field("Messaggio")]
		public string Messaggio
		{
			get 
			{ 
				return _messaggio; 
			}
			set 
			{
				if (value != null && value.Length > 1000)
					throw new ArgumentException("Value length must be between 0 and -1 characters.");

				_messaggio = value;

				OnRowChanged("Messaggio");
			}
		}

		/// <summary>
		/// This property is mapped to the "Urgenza" field.  
		/// Storage comment: .
		/// </summary>
		[Field("Urgenza")]
		public int? Urgenza
		{
			get 
			{ 
				return _urgenza; 
			}
			set 
			{
				_urgenza = value;

				OnRowChanged("Urgenza");
			}
		}

		/// <summary>
		/// This property is mapped to the "Scadenza" field.  
		/// Storage comment: .
		/// </summary>
		[Field("Scadenza")]
		public DateTime? Scadenza
		{
			get 
			{ 
				return _scadenza; 
			}
			set 
			{
				_scadenza = value;

				OnRowChanged("Scadenza");
			}
		}

		/// <summary>
		/// The foreign key connected with another persistent object.
		/// </summary>
		[Field("Fk_IDUser_Mittente", AllowDBNull = false)]
		public Guid Fk_IDUser_Mittente
		{
			get 
			{ 
				return _fk_IDUser_Mittente; 
			}
			private set 
			{
				_fk_IDUser_Mittente = value;

				OnRowChanged("Fk_IDUser_Mittente");
			}
		}

		/// <summary>
		/// This property is mapped to the "Mittente" field. Length must be between 0 and 50 characters. 
		/// Storage comment: .
		/// </summary>
		[Field("Mittente")]
		public string Mittente
		{
			get 
			{ 
				return _mittente; 
			}
			set 
			{
				if (value != null && value.Length > 50)
					throw new ArgumentException("Value length must be between 0 and 50 characters.");

				_mittente = value;

				OnRowChanged("Mittente");
			}
		}

		/// <summary>
		/// The foreign key connected with another persistent object.
		/// </summary>
		[Field("Fk_IDAttivitaIterStato")]
		public int? Fk_IDAttivitaIterStato
		{
			get 
			{ 
				return _fk_IDAttivitaIterStato; 
			}
			private set 
			{
				_fk_IDAttivitaIterStato = value;

				OnRowChanged("Fk_IDAttivitaIterStato");
			}
		}

		/// <summary>
		/// This property is mapped to the "DataCambioStato" field.  
		/// Storage comment: .
		/// </summary>
		[Field("DataCambioStato")]
		public DateTime? DataCambioStato
		{
			get 
			{ 
				return _dataCambioStato; 
			}
			set 
			{
				_dataCambioStato = value;

				OnRowChanged("DataCambioStato");
			}
		}

		/// <summary>
		/// This property is mapped to the "MessaggioRitorno" field. Length must be between 0 and -1 characters. 
		/// Storage comment: .
		/// </summary>
		[Field("MessaggioRitorno")]
		public string MessaggioRitorno
		{
			get 
			{ 
				return _messaggioRitorno; 
			}
			set 
			{
				if (value != null && value.Length > -1)
					throw new ArgumentException("Value length must be between 0 and -1 characters.");

				_messaggioRitorno = value;

				OnRowChanged("MessaggioRitorno");
			}
		}

		/// <summary>
		/// This property is mapped to the "IsTerminated" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("IsTerminated", AllowDBNull = false)]
		public bool IsTerminated
		{
			get 
			{ 
				return _isTerminated; 
			}
			set 
			{
				_isTerminated = value;

				OnRowChanged("IsTerminated");
			}
		}

		#endregion

		#region IObjectNotification Members

		/// <summary>
		/// Invoked by the framework before the persistent object is populated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforePopulated(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is populated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterPopulated(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework before the object is inserted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeInsert(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is inserted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterInsert(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework before the object is updated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeUpdate(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is updated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterUpdate(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework before the object is deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeDelete(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterDelete(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object has been marked deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeMarkDeleted(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object has been marked deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterMarkDeleted(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		#endregion

		#region ISelfContainingObject Members

		private ObjectInfo _objectInfo = null;

		/// <summary>
		/// Returns the <see cref="Opf3.ObjectInfo">ObjectInfo</see> object that contains all
		/// information required to make the persistent object
		/// <see cref="Opf3.ObjectContext">independent from any ObjectContext</see>.
		/// </summary>
		/// <value>
		/// 	<see cref="Opf3.ObjectInfo">ObjectInfo</see> object that holds the status
		/// information of the persistent object.
		/// </value>
		ObjectInfo ISelfContainingObject.ObjectInfo
		{
			get { return _objectInfo; }
			set { _objectInfo = value; }
		}

		#endregion

		#region INotifyPropertyChanged Members

		/// <summary>
		/// Invokes the "PropertyChanged" event if a property has been changed and
		/// somebody subscribed the event.
		/// </summary>
		private void OnRowChanged(string propertyName)
		{
			if (PropertyChanged != null)
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}

		/// <summary>
		/// Event is fired if a property of the persistent changed.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;

		#endregion
	}
}
